import React from 'react';
import Com from '../components/Com';
import { connect } from 'dva'
import { Button } from 'antd'

function HomePage(props) {
  const { home, dispatch, homeLoading } = props

  let div = home.map((item, index) => {
    return <h3 key = { index }>
      { item.title }
    </h3>
  })
  return (
    <div>
        {/* 我是Home --- { home }  <button onClick={() => {
          dispatch({ type: "home/change" })
        }}>点我</button> */}
        <Button>点我</Button>

        {
          homeLoading? "加载中~" : div
        }

        {/* <div>
          <button onClick={() => {
            dispatch({ type: "home/homeAsync" })
          }}>点我发起异步请求</button>
        </div> */}

        {/* <Com/> */}
    </div>
  );
}

const mapState = (state) => {
    console.log(state)
    const { home, loading } = state
    const homeLoading = loading.models.home
    return {
      home,
      homeLoading
    }
}

HomePage = connect(mapState)(HomePage)

export default HomePage
